home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / 3DMF parser / 1.0 version / MF3DPC / MF3D.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-07  |  7.7 KB  |  215 lines  |  [TEXT/dosa]

  1. #ifndef MF3D_H
  2. #define    MF3D_H
  3. /*==============================================================================
  4.  *
  5.  *    File:        MF3D.H
  6.  *
  7.  *    Function:    QuickDraw 3D Metafile Read/Write API
  8.  *
  9.  *    Version:    Metafile:    Version 1.0 3DMF files
  10.  *                Package:    Release #2 of this code
  11.  *
  12.  *    Author(s):    Rick Wong (RWW), Duet Development Corp.
  13.  *                John Kelly (JRK), Duet Development Corp.
  14.  *
  15.  *    Copyright:    (c) 1995 by Apple Computer, Inc., all rights reserved.
  16.  *
  17.  *    Example:    A simple metafile viewer will look something like:
  18.  *
  19.  *                MF3DOpenInputStdCFile(filename, &metafile);
  20.  *                while (MF3DReadAnObject(metafile, &object) != kMF3DErrNoMoreObjs)
  21.  *                {    if (object->objectType == kMF3DObjReference)
  22.  *                    {    MF3DResolveReference(metafile, object, NULL);
  23.  *                    }
  24.  *                    else
  25.  *                    {    switch(object->objectType)
  26.  *                        {    ...Handle each object type appropriately...
  27.  *                        }
  28.  *                    }
  29.  *                    DisposeObject(object);
  30.  *                }
  31.  *                MF3DClose(metafile);
  32.  *
  33.  *    Change History (most recent first):
  34.  *        FB7_JRK    Pragma macros
  35.  *        Fabio    Changed file name to 8 characters
  36.  *        F2R_RWW    Change to simple object theory.
  37.  *        F28_RWW    Finished definitions and added comments.
  38.  *        F21_RWW    File created.
  39.  *==============================================================================
  40.  */
  41. #if defined(applec) || defined(__MWERKS__) || defined(THINK_C)
  42. #pragma once
  43. #endif
  44.  
  45. #include "MFIOCALL.H"
  46. #include "MFOBJCTS.H"
  47. #include "MFTYPES.H"
  48. #include "MFINTOBJ.H"
  49.  
  50. #define    kMF3DVersionMajor    1
  51. #define    kMF3DVersionMinor    0
  52. #define    kAllowVariableUns    FALSE
  53.  
  54. /*==============================================================================
  55.  *    API Routines
  56.  *==============================================================================
  57.  */
  58.  
  59. /*==============================================================================
  60.  *    MF3DOpenInput
  61.  *
  62.  *    Open a metafile for parsing using caller-defined file-handling routines.
  63.  *==============================================================================
  64.  */
  65. MF3DErr
  66. MF3DOpenInput(
  67.     MF3DUserOpenDataPtr    inUserDataPtr,        /* In:  user-defined file info    */
  68.     MF3DProcsPtr        inUserIOProcsPtr,    /* In:  user-defined I/O procs    */
  69.     MF3D_FilePtr *        outMF3DFilePtr);    /* Out: MF3D file structure        */
  70.  
  71. /*==============================================================================
  72.  *    MF3DOpenInputStdCFile
  73.  *
  74.  *    Open a metafile for parsing using standard C routines.
  75.  *
  76.  *    This routine just calls MF3DOpenInput with inUserDataPtr = inFilename
  77.  *    and inUserIOProcsPtr set to call fopen, fread, NULL, ftell, fseek,
  78.  *    and fclose.
  79.  *==============================================================================
  80.  */
  81. MF3DErr
  82. MF3DOpenInputStdCFile(
  83.     const char *    inFilename,            /* In:  C-string filename            */
  84.     MF3D_FilePtr *    outMF3DFilePtr);    /* Out: MF3D file structure            */
  85.  
  86. /*==============================================================================
  87.  *    MF3DReadAnObject
  88.  *
  89.  *    Retrieve the next metafile object in an open metafile.
  90.  *
  91.  *    Metafile objects are defined in <MFOBJCTS.H>. They can be recognized
  92.  *        by checking the fObjectType field and casting the object pointer
  93.  *        appropriately.
  94.  *
  95.  *    Objects returned by MF3DReadAnObject should be disposed using
  96.  *        MF3DDisposeObject when they are no longer needed. If an error occurs,
  97.  *        NULL will be returned (MF3DDisposeObject ignores NULL parameters).
  98.  *
  99.  *    Returns:
  100.  *        kMF3DNoErr                object was successfully read
  101.  *        kMF3DNoMoreObjects        the end of the file has been reached
  102.  *==============================================================================
  103.  */
  104. MF3DErr
  105. MF3DReadAnObject(
  106.     MF3D_FilePtr    inMF3DFilePtr,        /* In:  MF3D file structure            */
  107.     MF3DVoidObjPtr *outMF3DObjPtr);        /* Out: metafile object                */
  108.  
  109. /*==============================================================================
  110.  *    MF3DDisposeObject
  111.  *
  112.  *    Dispose a metafile object.
  113.  *    If inMF3DObjPtr is NULL, nothing happens.
  114.  *==============================================================================
  115.  */
  116. MF3DErr
  117. MF3DDisposeObject(
  118.     MF3DVoidObjPtr    inMF3DObjPtr);        /* In:  metafile object                */
  119.  
  120. /*==============================================================================
  121.  *    MF3DResolveReference
  122.  *
  123.  *    Set up an MF3D file so that it will read the object pointed to by
  124.  *    a reference object. The next call to MF3DReadAnObject will then read
  125.  *    the referenced object, and the MF3D file will then be reset to read the
  126.  *    object that would have been read if MF3DResolveReference had not been
  127.  *    called.
  128.  *
  129.  *    If MF3DResolveReference resolves to a group object, the entire group will
  130.  *    be read before the MF3D file is reset.
  131.  *
  132.  *    If inStoragePtr is not NULL, the reference is in an external file.
  133.  *==============================================================================
  134.  */
  135. MF3DErr
  136. MF3DResolveReference(
  137.     MF3D_FilePtr        inMF3DFilePtr,         /* In:  MF3D file structure        */
  138.     MF3DReferenceObjPtr    inMF3DRefObjPtr,     /* In:  reference object        */
  139.     MF3DStorageObjPtr    inExternalFilePtr);    /* In:    external storage object    */
  140.  
  141. /*==============================================================================
  142.  *    MF3DClose
  143.  *
  144.  *    Close the metafile.
  145.  *
  146.  *    If inMF3DFilePtr is NULL, nothing happens.
  147.  *==============================================================================
  148.  */
  149. MF3DErr
  150. MF3DClose(
  151.     MF3D_FilePtr    inMF3DFilePtr);            /* In:  MF3D file structure        */
  152.  
  153. /*==============================================================================
  154.  *    MF3DOpenOutput
  155.  *
  156.  *    Open a metafile for writing using caller-defined file-handling routines.
  157.  *==============================================================================
  158.  */
  159. MF3DErr
  160. MF3DOpenOutput(
  161.     MF3DDataFormatEnum    inMF3DDataFormat,    /* In:  binary or text            */
  162.     MF3DUserOpenDataPtr    inUserDataPtr,        /* In:  user-defined file info    */
  163.     MF3DProcsPtr        inUserIOProcsPtr,    /* In:  user-defined I/O procs    */
  164.     MF3D_FilePtr *        outMF3DFilePtr);    /* Out: MF3D file structure        */
  165.  
  166. /*==============================================================================
  167.  *    MF3DOpenOutputStdCFile
  168.  *
  169.  *    Open a metafile for writing using standard C routines.
  170.  *
  171.  *    This routine just calls MF3DOpenOutput with inUserDataPtr = inFilename
  172.  *    and inUserIOProcsPtr set to call fopen, fread, fwrite, ftell, fseek,
  173.  *    and fclose.
  174.  *==============================================================================
  175.  */
  176. MF3DErr    MF3DOpenOutputStdCFile(
  177.     MF3DDataFormatEnum    inMF3DDataFormat,    /* In:  binary or text            */
  178.     const char *        inFilename,            /* In:  C-string filename        */
  179.     MF3D_FilePtr *        outMF3DFilePtr);    /* Out: MF3D file structure        */
  180.  
  181. /*==============================================================================
  182.  *    MF3DWriteAnObject
  183.  *
  184.  *    Write a metafile object to an open metafile.
  185.  *==============================================================================
  186.  */
  187. MF3DErr
  188. MF3DWriteAnObject(
  189.     MF3D_FilePtr    inMF3DFilePtr,            /* In:  MF3D file structure        */
  190.     MF3DVoidObjPtr    inMF3DObjPtr);            /* In:  metafile object            */
  191.  
  192. /*==============================================================================
  193.  *    MF3DTellPosition
  194.  *
  195.  *    Retrieve the position of an open metafile.
  196.  *==============================================================================
  197.  */
  198. MF3DErr
  199. MF3DTellPosition(
  200.     MF3D_FilePtr                inMF3DFilePtr,    /* In:  MF3D file structure    */
  201.     MF3DBinaryFilePosition *    outMF3DPosPtr);    /* Out: file offset            */
  202.  
  203. /*==============================================================================
  204.  *    MF3DSeekPosition
  205.  *
  206.  *    Set the position of an open metafile.
  207.  *==============================================================================
  208.  */
  209. MF3DErr
  210. MF3DSeekPosition(
  211.     MF3D_FilePtr            inMF3DFilePtr,        /* In:  MF3D file structure    */
  212.     MF3DBinaryFilePosition    inMF3DPosition);    /* In:  file offset            */
  213.  
  214. #endif
  215.